package com.yer.note.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.yer.note.R;
import com.yer.note.entity.User;

public class setting_Username extends AppCompatActivity {
    Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting_username);
        button = findViewById(R.id.setting_submit_username);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EditText newUsername = findViewById(R.id.setting_new_username);
                String newName = newUsername.getText().toString();
                User.user.setName(newName);
                User.update(User.user);
                String news = "用户名已经修改为："+newName;
                Toast.makeText(view.getContext(),news,Toast.LENGTH_SHORT).show();
                newUsername.setText("");
            }
        });
    }
}